home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6726 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.0 KB

  1. Path: the-fly.zip.com.au!not-for-mail
  2. From: stuartm@zip.com.au (Stuart Mackinnon)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Dynamic loading/linking
  5. Date: 1 Apr 1996 00:19:44 GMT
  6. Organization: Very Little
  7. Distribution: world
  8. Message-ID: <4jn7f0$k5f@the-fly.zip.com.au>
  9. References: <Dp0x52.90C.0.-s@cs.vu.nl> <4jgtg5$67h@ra.ibr.cs.tu-bs.de>
  10. NNTP-Posting-Host: zipper.zip.com.au
  11. X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
  12.  
  13. Lars Duening (duening@ibr.cs.tu-bs.de) wrote:
  14. > In article <Dp0x52.90C.0.-s@cs.vu.nl> irmen@cs.vu.nl (Irmen de Jong) writes:
  15. > >Say I want to split my program into separate parts (because it's
  16. > >getting too big, or because some parts are rarely used).
  17. > >(I'm talking about my port of the python interpreter here)
  18. > >
  19. > >What solutions  are feasible?
  20. > >
  21. > > [ Overlay, LoadSeg() snipped ]
  22. > >
  23. > >- Amiga shared library. Would be most ideal, but libraries cannot reference
  24. > >  global data. (Ok Ok they can by passing all the pointers to all the
  25. > >  global data you want to reference but in my case this is no option.
  26. > >  Way to much global data.)
  27. > Do it this way. With properly 'struct'ured global data, passing
  28. > pointers is easy (and in my experience leads to a cleaner design).
  29. > As an added bonus, you can run several instances of your program from
  30. > just one set of loaded executables.
  31.  
  32. Exactly.
  33.  
  34. Basically your application should have a main structure containing
  35. all global data. A pointer to this structure can then be passed to any
  36. functions within your librar[y|ies] (or functions within your executable)
  37. that needs the data.
  38.  
  39. By doing it this way, you can then have a pointer to this type of
  40. structure as a "stack" variable in main(). Then allocate memory for the
  41. size of the structure, initialise it and then use it. Your application is
  42. then basically re-entrant and re-executable, and can be made residentable.
  43.  
  44. If you are wanting to split it up because some parts are rarely used,
  45. and you do make it into shared libraries, make sure you only load the
  46. librar[y|ies] when you actually need them - otherwise there is not really
  47. much point (unless your going to run multiple copies of the app).
  48.  
  49. The other advantage to shared libraries is that you can update the
  50. libraries independantly of the main application - for fixing bugs, adding
  51. more functionality etc. They also have built in version numbers which
  52. is very useful, and can be used by Installer to make sure the latest
  53. version is installed - something you can't do with separate LoadSeg()'d
  54. modules.
  55.  
  56. I am sure there are advantages for usining LoadSeg()'d modules, or
  57. overlays, but there are so many more advantages with shareds libraries
  58. that basically there is no other choice (IMHO).
  59.  
  60. Regards,
  61.  
  62. Stuart MacKinnon.
  63. -- 
  64.  
  65. +- Stuart MacKinnon ------------------------------------ stuartm@zip.com.au -+
  66. |  VIC20, CBM 128+1571, A1000+Sidecar, CD32, A4000/040+A4091+A2065+RetinaZ3! |
  67. |  Registered BeBox Developer - for those at the bleeding edge.              |
  68. |  PHONE: +61 2 398 4578 (AH)                            +61 2 693 0445 (BH) |
  69. +--- Aztec C - Use it to MANXimise code inefficiency! -----------------------+
  70.